home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Hot Mix 17
/
Hot Mix 17.iso
/
HM17_SGI
/
research
/
examples
/
demo
/
demosrc
/
puttips.pro
< prev
next >
Wrap
Text File
|
1997-07-08
|
3KB
|
83 lines
pro putTips, $
sText, $ ; IN: text structure (fields : id, text)
widgetID, $ ; IN: widget text identifier
textArray, $ ; IN: string array to change from current settings.
position ; IN: integer array position of each text changes.
; Dimensions of textArray and position are the same.
; Verify the validity of the input parameters.
;
if (N_PARAMS() NE 4) then begin
PRINT,' Error in putTips.pro : you must pass 4 parameters.'
RETURN
endif
if ( WIDGET_INFO(widgetID, /NAME) NE 'TEXT') then begin
PRINT, 'Error in putTips.pro : WidgetID is not a widget text.'
RETURN
endif
if ( WIDGET_INFO(widgetID, /VALID_ID) EQ 0) then begin
PRINT, 'Error in putTips.pro : widget text ID not valid.'
RETURN
endif
sizeText = size(textArray)
if ( (sizeText[2] NE 7) OR (sizeText[0] NE 1) ) then begin
PRINT, 'Error in putTips.pro : text array must be a string array'
PRINT, 'and must be one dimensional.'
RETURN
endif
sizePosition = size(position)
if ( (sizePosition[2] NE 2) OR (sizePosition[0] NE 1) ) then begin
PRINT, 'Error in putTips.pro : positon array must be an '
PRINT, 'integer array and must be one dimensional.'
RETURN
endif
; Get the number of changes to make.
;
nChange = N_ELEMENTS(textArray)
; Get the existing text in the widget text.
;
WIDGET_CONTROL, widgetID, GET_VALUE=widgetText
; For the demo purpose only, we must assure that
; there are 3 text lines within the widget text.
; There may be cases where there are only 1 or
; 2 lines returned from the get_value call above.
;
nLinesText = N_ELEMENTS(widgetText)
maxLines = 3
if (nLinesText LT maxLines) then $
widgetText = [widgetText, STRARR(maxLines-nLinesText)]
; Make sure that the position is less that 3 (0,1, or 2).
; For demo purpose only.
;
if (MAX(position) GE maxLines) then begin
PRINT,'Error in puttips : the position must be less than '+ $
STRING(maxLines)
RETURN
endif
; Make the changes.
;
for j = 0, nChange-1 do begin
flag = 0
i = 0
while ( flag EQ 0) do begin
if (sText.id[i] EQ textArray[j]) then begin
widgetText[position[j]] = sText.text[i]
flag = 1
endif
i = i+1
endwhile
endfor
WIDGET_CONTROL, widgetID, SET_VALUE=widgetText
end ; of putTips